<?php defined('BASEPATH') OR die('No direct access allowed.');
/**
 * Description of "create-services"
 *
 * Created on Jan 14, 2011
 * @author Ramon Gutierrez
 * @copyright Bitstop Network Services Inc.
 * @version 0.1
 */
?>
			<?php if($this->session->userdata('account_type') == 'company'): ?>
            <script type="text/javascript">
			  // <![CDATA[
			  $(document).ready(function() {
				var use_preset = true;
				
				$("#use_preset").change(function() {
			      use_preset = $(this).attr("checked");
				  
				  if(use_preset) {
					$("#title, #prefix, #closing_codes").val("").attr("readonly", "readonly").css("fontStyle", "italic");
					$("#globals-box").fadeIn();
					$("#globals").val("").focus();
				  } else {
					$("#title, #prefix, #closing_codes").val("").attr("readonly", "").css("fontStyle", "");
					$("#globals-box").hide();
					$("#globals").val("");
					$("#title").focus();
				  }
				});
				
				$("#globals").change(function() {
				  if(use_preset) {
				    $.post('<?php echo site_url('services/getGlobalInfo'); ?>', { id: $(this).val() }, function(data) {
					  if(data) {
						$("#title").val(data.title);
						$("#prefix").val(data.prefix);
						$("#closing_codes").val(data.closing_codes);
					  } else {
						$("#title").val("");
						$("#prefix").val("");
						$("#closing_codes").val("");
					  }
					}, "json");
				  }
				});
				
				$("#use_preset").change();
				$("#globals").change();
			  });
			// ]]>
			</script>
            <?php endif; ?>
            <div id="body">
              <div class="sectionhead"><?php echo $this->lang->line('subtitle_create_service'); ?></div>
              <div id="response"></div>
              <form id="theform" method="post" action="<?php echo site_url($module . '/create_ajax'); ?>">
              <?php if($this->session->userdata('account_type') == 'company'): ?>
              <div style="margin-bottom: 10px;">
                <span class="label" style="display: inline-block; font-weight: normal;"><input checked="checked" type="checkbox" name="use_preset" id="use_preset" style="margin-right: 5px;" /><?php echo $this->lang->line('use_preset'); ?></span>
              </div>
              <?php endif; ?>
              <div class="row">
                <div class="firstcol">
                  <?php if($this->session->userdata('account_type') == 'company'): ?>
                  <div id="globals-box" style="display: none;">
                    <span class="label"><?php echo $this->lang->line('service_globals'); ?></span>
                    <select class="standard" name="globals" id="globals">
                    <option value="">Select one</option>
                    <?php foreach($globals->result_array() as $row): ?>
                    <?php echo '<option value="' . $row['id'] . '">' . $row['title'] . " ($row[prefix])" . '</option>'; ?>
                    <?php endforeach; ?>
                    </select>
                  </div>
                  <?php endif; ?>
                  <div>
                    <span class="label"><?php echo $this->lang->line('service_title'); ?></span>
                    <input class="standard" type="text" size="25" id="title" name="title" maxlength="256" />
                  </div>
                  <div>
                    <span class="label"><?php echo $this->lang->line('service_prefix'); ?></span>
                    <input class="standard" type="text" size="5"  title="<?php echo $this->lang->line('tooltip_service_prefix'); ?>" name="prefix" id="prefix" maxlength="2" />
                  </div>
                </div>
                <div class="nextcol" style="border-left: 1px solid #333333; padding: 8px 0 8px 15px; margin-top: -8px; margin-bottom: -8px;">
                  <div>
                    <span class="label"><?php echo $this->lang->line('service_closing_codes'); ?></span>
                    <textarea class="standard" rows="8" cols="50" id="closing_codes" name="closing_codes"></textarea>
                  </div>
                  <?php if($this->session->userdata('account_type') == 'company'): ?>
                  <div>
                    <span class="label"><?php echo $this->lang->line('service_description'); ?></span>
                    <textarea class="standard" rows="8" cols="50" name="description"></textarea>
                  </div>
                  <?php endif; ?>
                </div>
                <div style="clear: both;"></div>
              </div>
              <div style="margin-top: 8px; font-size: 0.9em;">
                <div class="firstcol">
                  <a class="button-form submit" href="javascript:void(null);" id="btn-submit" style="margin-right: 8px;"><img src="<?php echo site_url('images/btn-submit.png'); ?>" alt="" /><?php echo $this->lang->line('create'); ?></a>
                  <noscript><div><input type="submit" value="<?php echo $this->lang->line('save_changes'); ?>" /></div></noscript>
                </div>
                <div class="nextcol" style="margin: 0;">
                  <a class="button-form" id="btn-back" style="margin-right: 8px;" href="<?php echo site_url($module); ?>"><img src="<?php echo site_url('images/btn-back.png'); ?>" alt="" /><?php echo $this->lang->line('nav_cancel'); ?></a>
                </div>
                <div class="clear"></div>
              </div>
              </form>
            </div>
            